package company.baidu;

import org.omg.CORBA.INTERNAL;

import java.util.*;

/**
 * @author briarbear
 * @blog https://briarbear.github.io
 * @date 2018-09-11 19:48
 */
public class B01 {

    public static void main(String[] args) {

    }


    List<Integer> solution(int numCunstomer,int numProduct,List<List<Integer>> productList){


        HashMap<Integer,Integer> map = new HashMap<>();

        for (int i = 0; i < numCunstomer; i++) {
            List<Integer> list = productList.get(i);
            for (int j = 0; j < list.size(); j++) {
                if (map.containsKey(list.get(j))){
                    int num = map.get(list.get(j));
                    map.put(list.get(j),num+1);
                }else {
                    map.put(list.get(j),1);
                }
            }
        }

        int max = 0;
        for (Integer num : map.values()) {
            if (num > max) max = num;
        }
        List<Integer> res = new ArrayList<>();
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            if (entry.getValue() == max) res.add(entry.getKey());
        }

        Collections.sort(res);
        return res;
    }
}
